﻿using Sys.Core.Models.Dto;
using Sys.Core.Models.Queries;
using Sys.Core.Models.VO;
using Sys.Core.Providers;
using MiniFox.Components;
using MiniFox.Infrastructure;
using MiniFox.Platform.Applications;
using MiniFox.Platform.Applications.Auth;

namespace Sys.Core.Services
{
    [AutoResolve]
    public class OnlineService : ApiServiceBase, IOnlineService
    {
        public OnlineService(SystemPrincipal principal) : base(principal)
        {
        }

        [AutoWired]
        public IOnlineProvider Provider { get; set; }

        public void Logoff(params string[] ticketId)
        {
            this.Provider.Logoff(ticketId);
        }

        public ResultObject<IEnumerable<AuthCodeVo>> QueryAuthCode(PagedQueryObject<AuthQuery> authQuery)
        {
            return this.Provider.AuthCodeQuery(authQuery);
        }

        public ResultObject<IEnumerable<AuthTokenVo>> QueryAuthToken(PagedQueryObject<AuthQuery> authQuery)
        {
            return this.Provider.AuthTokenQuery(authQuery);
        }

        public ResultObject<IEnumerable<OnlineVo>> QueryOnline(PagedQueryObject<OnlineQuery> onlineQuery)
        {
            return this.Provider.OnlineQuery(onlineQuery);
        }

        public ResultObject<IEnumerable<SigninLogVo>> QuerySigninLog(PagedQueryObject<SignInQuery> signInQuery)
        {
            return this.Provider.SignInLogQuery(signInQuery);
        }

        public void RemoveAuthCode(RemoveAuthCodeDto removeAuthCodeDto)
        {
            this.Provider.RemoveAuthCode(removeAuthCodeDto.ApplicationID, removeAuthCodeDto.TicketID, removeAuthCodeDto.AuthCode);
        }

        public void RemoveAuthToken(RemoveAuthTokenDto removeAuthTokenDto)
        {
            this.Provider.RemoveAuthToken(removeAuthTokenDto.ApplicationID, removeAuthTokenDto.TicketID);
        }
    }
}